2892. Sum of
values
Find the sum of values for the function
in some integers..
Input. First line contains the number of points n (1 ≤ n ≤ 50). Next line contains n integers x1,
x2, ..., xn – the points where the
function must be calculated and summed up (0 ≤ |xi| ≤ 109).
Output. Print one number – the sum of function
values f(x) at given points. The
answer is correct if its accuracy is no less than 10-9.
Sample
Input
3
1 2 3
Sample
Output
7.83333333333333
SOLUTION
mathematics
Calculate the integer part of the sum in
the variable sum1, the fractional
part in the variable sum2.
scanf ("%d",
&n);
sum1 = sum2 = 0;
for (i = 0; i
< n; i++)
{
scanf ("%lf", &x);
sum1 +=
x;
sum2 +=
1.0 / x;
}
Print the
desired result as the sum of two variables.
printf ("%.12lf\n",
sum1 + sum2);